home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_073 / dio / dio.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  123 lines

  1.  
  2. /*
  3.  * DIO.H
  4.  *
  5.  *  (C)Copyright 1987 Matthew Dillon, All Rights Reserved
  6.  *  Freely distributable.  Donations welcome, I    guess.
  7.  *
  8.  *    Matthew    Dillon
  9.  *    891 Regal Rd.
  10.  *    Berkeley, Ca.    94708
  11.  *
  12.  */
  13.  
  14. #ifndef    MYLIB_DIO_H
  15. #define    MYLIB_DIO_H
  16. #include <exec/types.h>
  17. #include <exec/io.h>
  18. #include <exec/memory.h>
  19. #include <exec/ports.h>
  20. #include <devices/timer.h>
  21.  
  22. typedef    struct IORequest IOR;
  23. typedef    struct IOStdReq     STD;
  24. typedef    struct MsgPort     PORT;
  25.  
  26. /*
  27.  *    'to' is in microsections.  The IO request structure
  28.  *  pointer is optional    to dio_open().    If NULL, dio_open()
  29.  *  initializes    it's own IO request (to mostly zero).  You have
  30.  *  to provide an IO request structure,    for instance, if openning
  31.  *  a console device since the window pointer must be passed to
  32.  *  OpenDevice().
  33.  *
  34.  *    each DFD descriptor has    it's own signal.
  35.  *
  36.  *    dio_isdone() returns 1 if the channel is clear,    0 otherwise.
  37.  */
  38.  
  39. extern long dio_open();        /* dfd      = dio_open(devname,unit,flags,req)*/
  40. extern long dio_dup();        /* newdfd = dio_dup(dfd)    */
  41. extern STD *dio_ctl();        /* req    = dio_ctl(dfd,com,buf,len)        */
  42. extern STD *dio_ctl_to();    /* req    = dio_ctl_to(dfd,com,buf,len,to)    */
  43. extern STD *dio_wait();        /* req    = dio_wait(dfd)        */
  44. extern STD *dio_abort();    /* req    = dio_abort(dfd)    */
  45. extern STD *dio_isdone();    /* req    = dio_isdone(dfd)   */
  46. extern int dio_signal();    /* signm= dio_signal(dfd)   */
  47. extern void dio_close();    /*  dio_close(dfd)        */
  48. extern void dio_cloesgroup();    /*  dio_closegroup(dfd)        */
  49. extern void dio_cact();        /*  dio_cact(dfd,bool)        */
  50.  
  51.  
  52.  
  53. /*
  54.  * dio_simple()    and related macros return the !io_Error    field. That
  55.  * is, 0=ERROR,    1=OK
  56.  *
  57.  * dio_actual()    returns    the io_Actual field.
  58.  *
  59.  * NOTE: the io_Actual field may not be    set by the device if an
  60.  * error condition exists.  To make the    io_ctl() and io_ctl_to()
  61.  * call    automatically clear the    io_Actual field    before doing the
  62.  * io operation, use the DIO_CACT() call.  The reason this isn't
  63.  * done    automatically by default is that some devices require
  64.  * parameters to be passed in the io_Actual field (like    the
  65.  * timer.device).
  66.  *
  67.  *  Remember, Asyncronous IO is    done by    sending    -com instead of    com.
  68.  *
  69.  *    CALL                Syncronous IO   Asyncronous    IO
  70.  *
  71.  *  dio_simple(dfd,com)            0=ERROR, 1=OK   undefined
  72.  *  dio_actual(dfd,com)            io_Actual        undefined
  73.  *  dio_reset(dfd)            0=ERROR, 1=OK   n/a
  74.  *  dio_update(dfd)            0=ERROR, 1=OK   n/a
  75.  *  dio_clear(dfd)            0=ERROR, 1=OK   n/a
  76.  *  dio_stop(dfd)            0=ERROR, 1=OK   n/a
  77.  *  dio_start(dfd)            0=ERROR, 1=OK   n/a
  78.  *  dio_flush(dfd)            0=ERROR, 1=OK   n/a
  79.  *  dio_getreq(dfd)            returns a ptr to the IO
  80.  *                    request structure
  81.  *  NOTE: If you use the following, you    probably want to have the
  82.  *  device library automatically clear the io_Actual field before
  83.  *  sending the    request    so you get 0 if    an error occurs.  That
  84.  *  is:    dio_cact(dfd,1);
  85.  *
  86.  *
  87.  *  dio_read(dfd,buf,len)        returns actual bytes read
  88.  *  dio_write(dfd,buf,len)        returns actual bytes written
  89.  *
  90.  *    The timeout argument for dio_readto() and dio_writeto()
  91.  *    is in MICROSECONDS, up to 2^31uS.
  92.  *
  93.  *  dio_readto(dfd,buf,len,to)        returns actual bytes read
  94.  *  dio_writeto(dfd,buf,len,to)        returns actual bytes written
  95.  *
  96.  *    The asyncronous    dio_reada() and    dio_writea() do    not
  97.  *    return anything.
  98.  *
  99.  *  dio_reada(dfd,buf,len)        begin asyncronous read
  100.  *  dio_writea(dfd,buf,len)        begin asyncronous write
  101.  */
  102.  
  103. #define    dio_simple(dfd,com)    (!dio_ctl(dfd,com,0,0)->io_Error)
  104. #define    dio_actual(dfd,com)    ( dio_ctl(dfd,com,0,0)->io_Actual)
  105. #define    dio_reset(dfd)        dio_simple(dfd,CMD_RESET)
  106. #define    dio_update(dfd)        dio_simple(dfd,CMD_UPDATE)
  107. #define    dio_clear(dfd)        dio_simple(dfd,CMD_CLEAR)
  108. #define    dio_stop(dfd)        dio_simple(dfd,CMD_STOP)
  109. #define    dio_start(dfd)        dio_simple(dfd,CMD_START)
  110. #define    dio_flush(dfd)        dio_simple(dfd,CMD_FLUSH)
  111. #define    dio_getreq(dfd)        dio_ctl(dfd,0,0,0)
  112.  
  113. #define    dio_read(dfd,buf,len)        (dio_ctl(dfd,CMD_READ,buf,len)->io_Actual)
  114. #define    dio_write(dfd,buf,len)        (dio_ctl(dfd,CMD_WRITE,buf,len)->io_Actual)
  115. #define    dio_readto(dfd,buf,len,to)  (dio_ctl_to(dfd,CMD_READ,buf,len,to)->io_Actual)
  116. #define    dio_writeto(dfd,buf,len,to) (dio_ctl_to(dfd,CMD_WRITE,buf,len,to)->io_Actual)
  117. #define    dio_reada(dfd,buf,len)        ((void)dio_ctl(dfd,-CMD_READ,buf,len))
  118. #define    dio_writea(dfd,buf,len)        ((void)dio_ctl(dfd,-CMD_WRITE,buf,len))
  119.  
  120. #endif
  121.  
  122.  
  123.